package ru.niir.goodfil.audit.domain;

import ru.niir.goodfil.audit.domain.enums.LoginAction;
import ru.niir.goodfil.audit.util.Assert;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

@Entity
public class LoginEvent extends Event {
    @Enumerated(EnumType.STRING)
    private LoginAction action;

    private LoginEvent() {
    }

    public LoginEvent(String ip, String login, LoginAction action) {
        Assert.notBlank(login);
        Assert.notBlank(ip);
        Assert.notNull(action);

        this.ip = ip;
        this.login = login;
        this.action = action;
    }

    public LoginAction getAction() {
        return action;
    }

    public void setAction(LoginAction action) {
        this.action = action;
    }

    @Override
    public String toString() {
        return "LoginEvent{" +
                "action=" + action +
                '}';
    }
}
